package com.win.oauth.mapper;

import com.win.oauth.dto.FunPermissionDTO;
import com.win.oauth.entity.Fun;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author youlian.fei
 * @since 2020-03-14
 */
public interface FunMapper extends BaseMapper<Fun> {


    @Select({"SELECT fun.*, perm.id AS perm_id, perm.url AS url FROM sys_fun fun ",
            " LEFT JOIN sys_permission perm ON perm.module_fun_id = fun.id AND perm.type = 2",
            " WHERE fun.module_id = #{moduleId}",
            " ORDER BY fun.seq ASC, fun.id ASC "})
    List<FunPermissionDTO> selectByModule(@Param("moduleId") Long moduleId);


    Fun selectById(@Param("id") Long id);

}
